function e(e, t) {
    if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}

var t = function() {
    function e(e, t) {
        for (var i = 0; i < t.length; i++) {
            var s = t[i];
            s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), 
            Object.defineProperty(e, s.key, s);
        }
    }
    return function(t, i, s) {
        return i && e(t.prototype, i), s && e(t, s), t;
    };
}();

wxapp.ClsLib.Timer = function() {
    function i() {
        e(this, i), this.REPEAT_FOREVER = Number.MAX_VALUE - 1;
    }
    return t(i, [ {
        key: "schedule",
        value: function(e, t, i, s) {
            if (this.unschedule(), !(arguments.length < 2)) {
                if (2 == arguments.length) this.callback = e, this.interval = t, this.repeat = this.REPEAT_FOREVER, 
                this.delay = 0; else if (3 == arguments.length) this.callback = e, this.interval = t, 
                this.repeat = this.REPEAT_FOREVER, this.delay = i; else {
                    if (s < 1) return;
                    this.callback = e, this.interval = t, this.repeat = s, this.delay = i;
                }
                this.timerNumber1 = -1, this.timerNumber2 = -1, this.counter2 = 0, this.delay > 0 ? this.timerNumber1 = setTimeout(this._callbackDelay.bind(this), 1e3 * this.delay) : this._callbackDelay();
            }
        }
    }, {
        key: "scheduleOnce",
        value: function(e, t) {
            this.unschedule(), this.callback = e, this.timerNumber1 = setTimeout(this._callbackTimeout.bind(this), 1e3 * t);
        }
    }, {
        key: "_callbackDelay",
        value: function() {
            -1 != this.timerNumber1 && (clearTimeout(this.timerNumber1), this.timerNumber1 = -1), 
            this.repeat > 1 && (this.timerNumber2 = setInterval(this._callbackInterval.bind(this), 1e3 * this.interval)), 
            this.counter2++, this.callback(), this.counter2 >= this.repeat && this.unschedule();
        }
    }, {
        key: "_callbackInterval",
        value: function() {
            this.counter2 >= this.repeat ? this.unschedule() : (this.counter2++, this.callback());
        }
    }, {
        key: "_callbackTimeout",
        value: function() {
            this.unschedule(), this.callback();
        }
    }, {
        key: "unschedule",
        value: function() {
            -1 != this.timerNumber1 && clearTimeout(this.timerNumber1), -1 != this.timerNumber2 && clearInterval(this.timerNumber2), 
            this.timerNumber1 = -1, this.timerNumber2 = -1, this.counter2 = 0;
        }
    } ]), i;
}();